package edu.temple.templepatco;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * A single stop along a route
 */
public class Stop {

	private String name;

	private Date time;

	@SuppressWarnings("unused")
	/**
	 * A private constructor to prevent the creation of empty stops, never use this
	 */
	private Stop() {
	}

	/**
	 * Makes a single stop
	 * 
	 * @param name
	 *            The text label of the stop, e.g. "Girard"
	 * @param time
	 *            The time that the train arrives at the stop
	 */
	public Stop(String name, Date time) {
		super();
		this.name = name;
		this.time = time;
	}

	/**
	 * Returns the text label of the stop
	 * 
	 * @return the text label of the stop
	 */
	public String getName() {
		return name;
	}

	/**
	 * Returns the time that the train arrives at the stop
	 * 
	 * @return the time that the train arrives at the stop
	 */
	public Date getTime() {
		return (Date) time.clone();
	}

	@Override
	/**
	 * Creates a string containing the name and time of the stop formatted nicely
	 * @return a string containing the name and time of the stop formatted nicely
	 */
	public String toString() {
		SimpleDateFormat df = new SimpleDateFormat("h:mm a");
		return name + ": " + df.format(time);
	}

}
